/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package immt.ui;

import ij.ImagePlus;
import ij.process.FloatProcessor;
import immt.algorithms.snakes.externalforces.PotentialMcInerney99YDirection;
import immt.algorithms.snakes.imagedatafunction.FMcInerney99SignModified;
import immt.algorithms.snakes.tsnake.polar.TSnakePolar;
import immt.algorithms.structures.GreyScaleImage;
import immt.algorithms.structures.UndeterminedColumns;
import immt.util.Functions;
import immt.util.Matrix;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JFrame;

/**
 *
 * @author Gaston
 */
public class Snakes extends javax.swing.JFrame {

    
    private ImagePlus currentImage;

    private ShellWindow parent;
    
        /**
     * Creates new form Snakes
     */
    public Snakes() {
        initComponents();
    }
    
    /**
     * Creates new form Snakes
     */
    public Snakes(ImagePlus image, ShellWindow parent) {
        initComponents();
        currentImage = image;
        this.parent = parent;
                
        int topOffset = 20;
        
        if(parent.MinRoiX != 0 || parent.MinRoiY != 0)
            if(parent.GetPoint1() == null && parent.GetPoint2() == null)
                contour.setText("0");
            else
            {
                Point point1 = parent.GetPoint1();
                Point point2 = parent.GetPoint2();
                if (point1.y < point2.y)
                {
                   // int withoutOffset = point1.y - top;
                    int withOffset = point1.y - topOffset;
                    if(withOffset > 0)
                        contour.setText(String.valueOf(withOffset));
                    else
                        contour.setText(String.valueOf(0));
                }                    
                else
                {
                    int withOffset = point2.y - topOffset;
                    if(withOffset > 0)
                        contour.setText(String.valueOf(withOffset));
                    else
                        contour.setText(String.valueOf(0));
                } 
            }
    }   
    

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        P = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        gauss = new javax.swing.JTextField();
        potential = new javax.swing.JTextField();
        F = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        thresh = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        thresh1 = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        FuerzasInternas = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        s = new javax.swing.JTextField();
        b = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        a = new javax.swing.JTextField();
        d = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        Otros = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        i = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        contour = new javax.swing.JTextField();

        P.setBorder(javax.swing.BorderFactory.createTitledBorder("P"));

        jLabel1.setText("Radio Gauss: ");

        jLabel2.setText("Potential Scale:");

        gauss.setText("5");

        potential.setText("0");

        javax.swing.GroupLayout PLayout = new javax.swing.GroupLayout(P);
        P.setLayout(PLayout);
        PLayout.setHorizontalGroup(
            PLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PLayout.createSequentialGroup()
                .addGroup(PLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(18, 18, 18)
                        .addComponent(potential))
                    .addGroup(PLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(27, 27, 27)
                        .addComponent(gauss, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        PLayout.setVerticalGroup(
            PLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PLayout.createSequentialGroup()
                .addGroup(PLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(gauss, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(PLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(potential, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        F.setBorder(javax.swing.BorderFactory.createTitledBorder("F"));

        jLabel3.setText("Threshold Intensity #1: ");

        thresh.setText("53");

        jLabel10.setText("Threshold Intensity #2: ");

        thresh1.setText("180");

        jButton2.setText("Use Points");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout FLayout = new javax.swing.GroupLayout(F);
        F.setLayout(FLayout);
        FLayout.setHorizontalGroup(
            FLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(FLayout.createSequentialGroup()
                .addGroup(FLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(FLayout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addGap(27, 27, 27)
                        .addComponent(thresh1, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(FLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(27, 27, 27)
                        .addComponent(thresh, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton2)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        FLayout.setVerticalGroup(
            FLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(FLayout.createSequentialGroup()
                .addGroup(FLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(FLayout.createSequentialGroup()
                        .addGroup(FLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(thresh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(FLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel10)
                            .addComponent(thresh1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(FLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jButton2)))
                .addContainerGap())
        );

        FuerzasInternas.setBorder(javax.swing.BorderFactory.createTitledBorder("Fuerzas Internas"));

        jLabel4.setText("Stretching: ");

        jLabel5.setText("Bending:");

        s.setText("20");

        b.setText("0");

        jLabel6.setText("Damping:");

        a.setText("10");

        d.setText("30");

        jLabel7.setText("Amplitude:");

        javax.swing.GroupLayout FuerzasInternasLayout = new javax.swing.GroupLayout(FuerzasInternas);
        FuerzasInternas.setLayout(FuerzasInternasLayout);
        FuerzasInternasLayout.setHorizontalGroup(
            FuerzasInternasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(FuerzasInternasLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(FuerzasInternasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(FuerzasInternasLayout.createSequentialGroup()
                        .addGroup(FuerzasInternasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7))
                        .addGap(32, 32, 32)
                        .addGroup(FuerzasInternasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(d)
                            .addComponent(a)))
                    .addGroup(FuerzasInternasLayout.createSequentialGroup()
                        .addGroup(FuerzasInternasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5))
                        .addGap(27, 27, 27)
                        .addGroup(FuerzasInternasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(b)
                            .addComponent(s)))))
        );
        FuerzasInternasLayout.setVerticalGroup(
            FuerzasInternasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(FuerzasInternasLayout.createSequentialGroup()
                .addGroup(FuerzasInternasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(s, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(FuerzasInternasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(b, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(FuerzasInternasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(d, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(FuerzasInternasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(a, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11))
        );

        jButton1.setText("Run Snakes");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        Otros.setBorder(javax.swing.BorderFactory.createTitledBorder("Otras"));

        jLabel8.setText("Iteraciones:");

        i.setText("250");

        jLabel9.setText("Initial Contour");

        contour.setText("372");

        javax.swing.GroupLayout OtrosLayout = new javax.swing.GroupLayout(Otros);
        Otros.setLayout(OtrosLayout);
        OtrosLayout.setHorizontalGroup(
            OtrosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(OtrosLayout.createSequentialGroup()
                .addGap(0, 47, Short.MAX_VALUE)
                .addGroup(OtrosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, OtrosLayout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addGap(27, 27, 27)
                        .addComponent(i, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, OtrosLayout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addGap(27, 27, 27)
                        .addComponent(contour, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))))
        );
        OtrosLayout.setVerticalGroup(
            OtrosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(OtrosLayout.createSequentialGroup()
                .addGroup(OtrosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(i, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(OtrosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(contour, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(151, 151, 151)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(FuerzasInternas, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(P, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(Otros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(F, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(F, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(P, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(FuerzasInternas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Otros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        BufferedImage buffImage = currentImage.getBufferedImage();
        
        GreyScaleImage filtrada = new GreyScaleImage(buffImage);
                
        // Cual es el Radio de Gauss???
        PotentialMcInerney99YDirection P = new PotentialMcInerney99YDirection(filtrada, Integer.parseInt(gauss.getText()), Integer.parseInt(potential.getText())); //Aca pongan potentialScale=0, no vamos a usar el gradiente de la imagen
        
        //Lumen - Intima : 53
        FMcInerney99SignModified F = new FMcInerney99SignModified(filtrada, Integer.parseInt(thresh.getText()), true);
        
        int stretching = Integer.parseInt(s.getText());
        
        int bending = Integer.parseInt(b.getText());
        
        int damping = Integer.parseInt(d.getText());
        
        int amplitude = Integer.parseInt(a.getText());
        
        int iterations = Integer.parseInt(i.getText());
        
        int[] initialCountour = new int[currentImage.getWidth()];
        
        for(int i = 0; i < currentImage.getWidth() ; i++)
            initialCountour[i] = Integer.parseInt(contour.getText());
        
        TSnakePolar tsnake = new TSnakePolar();
                
        BufferedImage img = tsnake.ejecutar(filtrada, new UndeterminedColumns(), P, F, damping, amplitude, stretching, bending, 0, 1., iterations, initialCountour,false , TSnakePolar.GRADIENTE_LIBRE);

        double[] topSnakeY = tsnake.getY();

         //System.out.println("SNAKE: " + topSnakeY.length);
        
        //System.out.println("WIDTH: " + img.getWidth());
        
        //System.out.println("HEITH: " + img.getHeight());
        
        //System.out.println("MIN X: " + parent.MinRoiX);
        
         //System.out.println("MIN Y: " + parent.MinRoiY);
        

        
        /*
        try {
            // retrieve image
            File outputfile = new File("D:\\snake.bmp");
            ImageIO.write(img, "bmp", outputfile);
        } catch (IOException e) {
            e.printStackTrace();
        }
        */
        // Media - Adventicia : 180
        F = new FMcInerney99SignModified(filtrada, Integer.parseInt(thresh1.getText()), true);        
        
        img = tsnake.ejecutar(filtrada, new UndeterminedColumns(), P, F, damping, amplitude, stretching, bending, 0, 1., iterations, initialCountour,false , TSnakePolar.GRADIENTE_LIBRE);

       
        
        
         //panel.setPreferredSize(new Dimension(img.getWidth(), img.getHeight()));
        
        double[] botSnakeY = tsnake.getY();
        
        for(int i = 0; i < img.getWidth() - 1 ; i++)
        {
           // System.out.println("SNAKE: " + (int)topSnakeY[i]);
            
            //System.out.println("DIFF: " + ((int)topSnakeY[i] -  parent.MinRoiY));+
             img.setRGB(i, (int)topSnakeY[i], Color.YELLOW.getRGB());
            img.setRGB(i, (int)botSnakeY[i], Color.BLUE.getRGB());
        }
                
        
         SnakesResult resultFrame = new SnakesResult(new ImagePlus("snakes", img), topSnakeY, botSnakeY);
         
          
        ImagePanel panel = new ImagePanel(new ImagePlus("snakes", img), null);

         //Set default close operation for JFrame  
         resultFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);  
 
         //frame.setSize(panel.getWidth(),panel.getHeight());  
        // resultFrame.pack();
         //Make JFrame visible. So we can see it  
         resultFrame.setVisible(true);  
             
        this.setVisible(false);
    }//GEN-LAST:event_jButton1ActionPerformed

    int windowSize = 10;
    
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        currentImage.setProcessor(currentImage.getProcessor().convertToFloat());
        float[] imagePixels = (float[]) currentImage.getProcessor().getPixelsCopy();

        Matrix imageMatrix = new Matrix(currentImage.getHeight(), currentImage.getWidth(), imagePixels);
        
        Point point1 = parent.GetPoint1();
        Matrix window1;
        if(point1 != null)
        {
            window1 = Functions.GetWindow(imageMatrix, new immt.util.Point(point1.x, point1.y), windowSize);
            thresh.setText(String.valueOf((int)Math.floor(GetAverageIntensityInWindow(window1))));    
        }
        Point point2 = parent.GetPoint2();
        Matrix window2;
        if(point2 != null)
        {
            window2 = Functions.GetWindow(imageMatrix, new immt.util.Point(point2.x, point2.y), windowSize);
            thresh1.setText(String.valueOf((int)Math.floor(GetAverageIntensityInWindow(window2))));
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    
    private float GetAverageIntensityInWindow(Matrix window)
    {
      float sum = 0;
      int[] intensityCheatSet = {85, 110, 130, 180, 190, 200, 210};
      for (int i = 0; i < windowSize ; i++) {
        for (int j = 0; j < windowSize ; j++) {
            sum += window.getElementAt(i, j);
        }
      }
      
      sum /= (windowSize * windowSize);
      
      if (sum > 150) {
       sum -=10;
      }
      
      for (int i : intensityCheatSet) {
          if(sum < i) {
              return i;
          }
      }
      return intensityCheatSet[intensityCheatSet.length-1];
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Snakes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Snakes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Snakes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Snakes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Snakes().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel F;
    private javax.swing.JPanel FuerzasInternas;
    private javax.swing.JPanel Otros;
    private javax.swing.JPanel P;
    private javax.swing.JTextField a;
    private javax.swing.JTextField b;
    private javax.swing.JTextField contour;
    private javax.swing.JTextField d;
    private javax.swing.JTextField gauss;
    private javax.swing.JTextField i;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField potential;
    private javax.swing.JTextField s;
    private javax.swing.JTextField thresh;
    private javax.swing.JTextField thresh1;
    // End of variables declaration//GEN-END:variables
}
